package entities;

import java.util.*;

/**
 *
 * @author Dragan Sahpaski
 */
public class Relation extends Table {

    public Relation(String name, int numberOfTuples, PrimaryKey primaryKey, List<Atribute> descriptiveAtributes) {
        super(name, numberOfTuples, primaryKey, descriptiveAtributes);
    }

    public static Relation getNullRelation() {
        return new Relation("NULL", 1, new PrimaryKey(new Atribute("NULL_ID")), new ArrayList<Atribute>());
    }

    @Override
    public boolean isTableMaterialized() {
        return true;
    }

    public static void addRelationship(Table child, Table parent) {
        parent.fkRelations.add(child);
        if (!child.parents.contains(parent)) {
            child.parents.add(parent);
        }
    }
}
